﻿var refreshGirdData; // 更新数据

var companyId = '';
var ztId = '';
var kjnd = '';
var kjqj = '';
var pzrqStart = '';
var pzrqEnd = '';
var userdefault = {};
var alreadyformat = false;
var params = {};

var bootstrap = function ($, learun) {

    var pageWidth = 1024;

    "use strict";
    var page = {
        init: function () {
            userdefault = learun.clientdata.get(['usersetting']);
            //初始化打印插件
            hiprint.init();
            pageWidth = ($('.lr-layout-grid').width());
            page.initGrid();
            page.bind();

        },
        bind: function () {

            $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
                // 调用后台查询
                // queryJson 查询条件
                page.search(queryJson);

            }, 230, 800);
            // 公司选择
            $('#company_select').lrselect({
                type: 'tree',
                // placeholder: '请选择机构',
                height: 300,
                maxHeight: 300,
                // 是否允许搜索
                //allowSearch: true,
                select: function (item) {
                    if (item && item.value != '-1') {
                        companyId = item.value;

                        $('#zt_select').lrselectRefresh({
                            // 访问数据接口地址
                            url: config.base_server() + 'zts/dropdownlist?access_token=' + config.getToken().access_token,
                            // 访问数据接口参数
                            param: {companyId: companyId},
                            select: function (ztItem) {
                                if (!ztItem || ztItem.value == '-1') {
                                    ztId = "";
                                } else {
                                    ztId = ztItem.value;
                                    $("#zt_title").html(ztItem.text);
                                    $('#kjnd_select').lrselectRefresh({
                                        // 访问数据接口地址
                                        url: config.base_server() + 'kjnds/dropdownlist?access_token=' + config.getToken().access_token,
                                        // 访问数据接口参数
                                        param: {companyId: companyId, ztId: ztItem.value},
                                    }).lrselectSet(userdefault.kjnd);
                                }
                            }
                        }).lrselectSet(userdefault.ztId);
                    }
                }
            });
            $('#company_select').lrselectRefresh({
                // 访问数据接口地址
                url: config.base_server() + 'companys/tree?access_token=' + config.getToken().access_token,
                // 访问数据接口参数
                param: {parentId: '0'}
            }).lrselectSet(userdefault.companyId);
            // 帐套选择
            $('#zt_select').lrselect({
                type: 'default',
                //placeholder: '请选择帐套',
                // 展开最大高度
                maxHeight: 300
            });
            // 会计年度选择
            $('#kjnd_select').lrselect({
                type: 'default',
                //placeholder: '请选择会计年度',
                // 展开最大高度
                maxHeight: 300,
                select: function (item) {
                    if (!item || item.value == '-1') {
                        kjnd = '';
                    } else {
                        kjnd = item.value;

                        var beginDate = kjnd + "-01-01";
                        var day = new Date(kjnd, 12, 0);
                        var endDate = kjnd + "-12-" + day.getDate();
                        $("#pzrqStart").val(beginDate);
                        $("#pzrqEnd").val(endDate);

                        page.search();
                    }
                }
            });
            $('#pzrqMonth').lrselect({
                type: 'default',
                // 展开最大高度
                maxHeight: 300,
                placeholder: '月份',
                data: [
                    {'id': '01', 'text': '01'},
                    {'id': '02', 'text': '02'},
                    {'id': '03', 'text': '03'},
                    {'id': '04', 'text': '04'},
                    {'id': '05', 'text': '05'},
                    {'id': '06', 'text': '06'},
                    {'id': '07', 'text': '07'},
                    {'id': '08', 'text': '08'},
                    {'id': '09', 'text': '09'},
                    {'id': '10', 'text': '10'},
                    {'id': '11', 'text': '11'},
                    {'id': '12', 'text': '12'}
                ],
                select: function (item) {
                    if (!item || item.id == '-1') {
                        var beginDate = kjnd + "-01-01";
                        var day = new Date(kjnd, 12, 0);
                        var endDate = kjnd + "-" + 12 + "-" + day.getDate();
                        $("#pzrqStart").val(beginDate);
                        $("#pzrqEnd").val(endDate);
                    } else {
                        var kjqj = item.id;
                        var beginDate = kjnd + "-" + kjqj + "-01";
                        var day = new Date(kjnd, kjqj, 0);
                        var endDate = kjnd + "-" + kjqj + "-" + day.getDate();
                        $("#pzrqStart").val(beginDate);
                        $("#pzrqEnd").val(endDate);
                    }
                }
            });
            // 刷新
            $('#lr_refresh').on('click', function () {
                location.reload();
            });
            // 查询
            $('#btn_Search').on('click', function () {
                page.search(params);
            });
            //打印
            $('#lr_print').on('click', function () {
                var formData = $('.lr-query-formcontent').lrGetFormData();

                var tempName = "zcfzb2";
                var hiprintTemplate = null;
                if(kjnd <= 2021) {
                    tempName = "zcfzb";
                }
                learun.httpAsyncGet2(config.base_server() + 'printTempletes/findByCode', "&companyId=" + companyId + '&ztId=' + ztId + '&code=' + tempName, function (res) {
                    if (res.resp_code == 200) {
                        hiprintTemplate = new hiprint.PrintTemplate({
                            template: JSON.parse(res.data.templete),
                            paginationContainer: '.hiprint-printPagination'
                        });

                        //hiprintTemplate.design('#hiprint-printTemplate');
                        var pzrq = $("#pzrqEnd").val();
                        $.ajax({
                            url: config.base_server() + 'report2s/zcfzb2?companyId=' + companyId + '&ztId=' + ztId + '&kjnd=' + kjnd + '&pzrqStart=' + params.pzrqStart + '&pzrqEnd=' + params.pzrqEnd + '&isSh=' + params.isSh + '&isJizhang=' + params.isJizhang + '&access_token=' + config.getToken().access_token,
                            type: "post",
                            dataType: "json",
                            success: function (res) {
                                if (res.resp_code == 200) {
                                    var item = {};

                                    item.pzrq = pzrq.substr(0, 4) + "年" + pzrq.substr(5, 2) + "月" + pzrq.substr(8, 10) + "日";
                                    item.ztName = res.data.ztName;
                                    for (var i = 0; i < res.data.list.length; i++) {
                                        switch (res.data.list[i].kjkmCode) {
                                            case "101":
                                                item.k101_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k101_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k101_ncye=='0.00'){
                                                    item.k101_ncye='';
                                                }
                                                if(item.k101_ye=='0.00'){
                                                    item.k101_ye='';
                                                }

                                                break;
                                            case "102":
                                                item.k102_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k102_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k102_ncye=='0.00'){
                                                    item.k102_ncye='';
                                                }
                                                if(item.k102_ye=='0.00'){
                                                    item.k102_ye='';
                                                }

                                                break;
                                            case "111":
                                                item.k111_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k111_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k111_ncye=='0.00'){
                                                    item.k111_ncye='';
                                                }
                                                if(item.k111_ye=='0.00'){
                                                    item.k111_ye='';
                                                }

                                                break;
                                            case "112":
                                                item.k112_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k112_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k112_ncye=='0.00'){
                                                    item.k112_ncye='';
                                                }
                                                if(item.k112_ye=='0.00'){
                                                    item.k112_ye='';
                                                }

                                                break;
                                            case "121":
                                                item.k121_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k121_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k121_ncye=='0.00'){
                                                    item.k121_ncye='';
                                                }
                                                if(item.k121_ye=='0.00'){
                                                    item.k121_ye='';
                                                }

                                                break;
                                            case "131":
                                                item.k131_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k131_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k131_ncye=='0.00'){
                                                    item.k131_ncye='';
                                                }
                                                if(item.k131_ye=='0.00'){
                                                    item.k131_ye='';
                                                }

                                                break;
                                            case "132":
                                                item.k132_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k132_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k132_ncye=='0.00'){
                                                    item.k132_ncye='';
                                                }
                                                if(item.k132_ye=='0.00'){
                                                    item.k132_ye='';
                                                }

                                                break;
                                            case "135":
                                                item.k135_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k135_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k135_ncye=='0.00'){
                                                    item.k135_ncye='';
                                                }
                                                if(item.k135_ye=='0.00'){
                                                    item.k135_ye='';
                                                }

                                                break;
                                            case "141":
                                                item.k141_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k141_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k141_ncye=='0.00'){
                                                    item.k141_ncye='';
                                                }
                                                if(item.k141_ye=='0.00'){
                                                    item.k141_ye='';
                                                }

                                                break;
                                            case "151":
                                                item.k151_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k151_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k151_ncye=='0.00'){
                                                    item.k151_ncye='';
                                                }
                                                if(item.k151_ye=='0.00'){
                                                    item.k151_ye='';
                                                }

                                                break;
                                            case "161":
                                                item.k161_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k161_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k161_ncye=='0.00'){
                                                    item.k161_ncye='';
                                                }
                                                if(item.k161_ye=='0.00'){
                                                    item.k161_ye='';
                                                }

                                                break;
                                            case "162":
                                                item.k162_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k162_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k161_ncye=='0.00'){
                                                    item.k161_ncye='';
                                                }
                                                if(item.k161_ye=='0.00'){
                                                    item.k161_ye='';
                                                }

                                                break;
                                            case "163":
                                                item.k163_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k163_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k163_ncye=='0.00'){
                                                    item.k163_ncye='';
                                                }
                                                if(item.k163_ye=='0.00'){
                                                    item.k163_ye='';
                                                }

                                                break;
                                            case "201":
                                                item.k201_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k201_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k201_ncye=='0.00'){
                                                    item.k201_ncye='';
                                                }
                                                if(item.k201_ye=='0.00'){
                                                    item.k201_ye='';
                                                }

                                                break;
                                            case "202":
                                                item.k202_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k202_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k202_ncye=='0.00'){
                                                    item.k202_ncye='';
                                                }
                                                if(item.k202_ye=='0.00'){
                                                    item.k202_ye='';
                                                }

                                                break;
                                            case "203":
                                                item.k203_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k203_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k203_ncye=='0.00'){
                                                    item.k203_ncye='';
                                                }
                                                if(item.k203_ye=='0.00'){
                                                    item.k203_ye='';
                                                }

                                                break;
                                            case "211":
                                                item.k211_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k211_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k211_ncye=='0.00'){
                                                    item.k211_ncye='';
                                                }
                                                if(item.k211_ye=='0.00'){
                                                    item.k211_ye='';
                                                }

                                                break;
                                            case "221":
                                                item.k221_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k221_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k221_ncye=='0.00'){
                                                    item.k221_ncye='';
                                                }
                                                if(item.k221_ye=='0.00'){
                                                    item.k221_ye='';
                                                }

                                                break;
                                            case "222":
                                                item.k222_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k222_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k222_ncye=='0.00'){
                                                    item.k222_ncye='';
                                                }
                                                if(item.k222_ye=='0.00'){
                                                    item.k222_ye='';
                                                }

                                                break;
                                            case "225":
                                                item.k225_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k225_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k225_ncye=='0.00'){
                                                    item.k225_ncye='';
                                                }
                                                if(item.k225_ye=='0.00'){
                                                    item.k225_ye='';
                                                }

                                                break;
                                            case "231":
                                                item.k231_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k231_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k231_ncye=='0.00'){
                                                    item.k231_ncye='';
                                                }
                                                if(item.k231_ye=='0.00'){
                                                    item.k231_ye='';
                                                }

                                                break;
                                            case "301":
                                                item.k301_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k301_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k301_ncye=='0.00'){
                                                    item.k301_ncye='';
                                                }
                                                if(item.k301_ye=='0.00'){
                                                    item.k301_ye='';
                                                }

                                                break;
                                            case "302":
                                                item.k302_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k302_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k302_ncye=='0.00'){
                                                    item.k302_ncye='';
                                                }
                                                if(item.k302_ye=='0.00'){
                                                    item.k302_ye='';
                                                }

                                                break;
                                            case "311":
                                                item.k311_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k311_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k311_ncye=='0.00'){
                                                    item.k311_ncye='';
                                                }
                                                if(item.k311_ye=='0.00'){
                                                    item.k311_ye='';
                                                }

                                                break;
                                            case "321":
                                                item.k321_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k321_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k321_ncye=='0.00'){
                                                    item.k321_ncye='';
                                                }
                                                if(item.k321_ye=='0.00'){
                                                    item.k321_ye='';
                                                }

                                                break;
                                            case "322":
                                                item.k322_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k322_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k322_ncye=='0.00'){
                                                    item.k322_ncye='';
                                                }
                                                if(item.k322_ye=='0.00'){
                                                    item.k322_ye='';
                                                }

                                                break;
                                            case "331":
                                                item.k331_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.k331_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                if(item.k331_ncye=='0.00'){
                                                    item.k331_ncye='';
                                                }
                                                if(item.k331_ye=='0.00'){
                                                    item.k331_ye='';
                                                }

                                                break;
                                            case "zc_total":
                                                item.zc_total_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.zc_total_ye = $.formatMoney(res.data.list[i].ye, 2);

                                                break;
                                            case "fz_total":
                                                item.fz_total_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.fz_total_ye = $.formatMoney(res.data.list[i].ye, 2);
                                                break;
                                            case "jzc_total":
                                                item.jzc_total_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.jzc_total_ye = $.formatMoney(res.data.list[i].ye, 2);
                                                break;
                                            case "zj_total":
                                                item.zj_total_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                                item.zj_total_ye = $.formatMoney(res.data.list[i].ye, 2);
                                                break;

                                        }
                                    }
                                    item.k103_ncye = $.formatMoney( $.unformatMoney2(item.k101_ncye)+$.unformatMoney2(item.k102_ncye),2);
                                    item.k103_ye = $.formatMoney( $.unformatMoney2(item.k101_ye)+$.unformatMoney2(item.k102_ye),2);

                                    item.k164_ncye = $.formatMoney( $.unformatMoney2(item.k162_ncye)-$.unformatMoney2(item.k163_ncye),2);
                                    item.k164_ye = $.formatMoney( $.unformatMoney2(item.k162_ye)-$.unformatMoney2(item.k163_ye),2);

                                    item.k144_ncye = $.formatMoney( $.unformatMoney2(item.k103_ncye)+$.unformatMoney2(item.k111_ncye)+$.unformatMoney2(item.k112_ncye)+$.unformatMoney2(item.k131_ncye)+$.unformatMoney2(item.k132_ncye)+$.unformatMoney2(item.k135_ncye)+$.unformatMoney2(item.k141_ncye),2);
                                    item.k144_ye = $.formatMoney( $.unformatMoney2(item.k103_ye)+$.unformatMoney2(item.k111_ye)+$.unformatMoney2(item.k112_ye)+$.unformatMoney2(item.k131_ye)+$.unformatMoney2(item.k132_ye)+$.unformatMoney2(item.k135_ye)+$.unformatMoney2(item.k141_ye),2);

                                    hiprintTemplate.resetPage();

                                    var htmlObj = hiprintTemplate.getHtml(item);
                                    $('.prevViewDiv2').html(htmlObj);

                                    hiprintTemplate.print(item);
                                }
                            }
                        })
                    }
                });
                $('#A4_printByHtml').click(function () {
                    hiprintTemplate.printByHtml($('#myModal .modal-body .prevViewDiv'));
                })
            });

            //导出Excel
            $("#lr_export_excel").on('click', function () {
                if (params.companyId == undefined) {
                    learun.alert.warning('请先查询要导出的数据！');
                    return;
                }
                params.access_token = config.getToken().access_token;
                var tempName = "zcfzb2";
                var hiprintTemplate = null;
                if(kjnd <= 2021) {
                    tempName = "zcfzb";
                }
                learun.download({
                    url: config.base_server() + 'report2s/'+tempName+'/excel',
                    param: params
                });
            });
            //导出pdf
            $("#lr_export_pdf").on('click', function () {
                if (params.companyId == undefined) {
                    learun.alert.warning('请先查询要导出的数据！');
                    return;
                }
                params.access_token = config.getToken().access_token;
                var tempName = "zcfzb2";
                var hiprintTemplate = null;
                if(kjnd <= 2021) {
                    tempName = "zcfzb";
                }
                learun.download({
                    url: config.base_server() + 'report2s/'+tempName+'/pdf',
                    param: params
                });
            });
        },
        initGrid: function () {

        },
        search: function (param) {
            param = param || {};
            var pzrqStart = $("#pzrqStart").val();
            var pzrqEnd = $("#pzrqEnd").val();
            param.companyId = companyId;
            param.ztId = ztId;
            param.kjnd = kjnd;
            param.pzrqStart = pzrqStart;
            param.pzrqEnd = pzrqEnd;

            var formData = $('.lr-query-formcontent').lrGetFormData();
            param.isSh = formData.isSh;
            param.isJizhang = formData.isJizhang;
            params = param;


            var tempName = "zcfzb2";
            var hiprintTemplate = null;
            if(kjnd <= 2021) {
                tempName = "zcfzb";
            }
            learun.httpAsyncGet2(config.base_server() + 'printTempletes/findByCode', "&companyId=" + companyId + '&ztId=' + ztId + '&code=' + tempName , function (res) {
                if (res.resp_code == 200) {
                    hiprintTemplate = new hiprint.PrintTemplate({
                        template: JSON.parse(res.data.templete),
                        paginationContainer: '.hiprint-printPagination'
                    });

                    //hiprintTemplate.design('#hiprint-printTemplate');
                    var pzrq = $("#pzrqEnd").val();
                    $.ajax({
                        url: config.base_server() + 'report2s/zcfzb2?companyId=' + companyId + '&ztId=' + ztId + '&kjnd=' + kjnd + '&pzrqStart=' + param.pzrqStart + '&pzrqEnd=' + param.pzrqEnd + '&isSh=' + param.isSh + '&isJizhang=' + param.isJizhang + '&access_token=' + config.getToken().access_token,
                        type: "post",
                        dataType: "json",
                        success: function (res) {
                            if (res.resp_code == 200) {
                                var item = {};

                                item.pzrq = pzrq.substr(0, 4) + "年" + pzrq.substr(5, 2) + "月" + pzrq.substr(8, 10) + "日";
                                item.ztName = res.data.ztName;
                                for (var i = 0; i < res.data.list.length; i++) {
                                    switch (res.data.list[i].kjkmCode) {
                                        case "101":
                                            item.k101_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k101_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k101_ncye=='0.00'){
                                                item.k101_ncye='';
                                            }
                                            if(item.k101_ye=='0.00'){
                                                item.k101_ye='';
                                            }

                                            break;
                                        case "102":
                                            item.k102_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k102_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k102_ncye=='0.00'){
                                                item.k102_ncye='';
                                            }
                                            if(item.k102_ye=='0.00'){
                                                item.k102_ye='';
                                            }

                                            break;
                                        case "111":
                                            item.k111_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k111_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k111_ncye=='0.00'){
                                                item.k111_ncye='';
                                            }
                                            if(item.k111_ye=='0.00'){
                                                item.k111_ye='';
                                            }

                                            break;
                                        case "112":
                                            item.k112_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k112_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k112_ncye=='0.00'){
                                                item.k112_ncye='';
                                            }
                                            if(item.k112_ye=='0.00'){
                                                item.k112_ye='';
                                            }

                                            break;
                                        case "121":
                                            item.k121_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k121_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k121_ncye=='0.00'){
                                                item.k121_ncye='';
                                            }
                                            if(item.k121_ye=='0.00'){
                                                item.k121_ye='';
                                            }

                                            break;
                                        case "131":
                                            item.k131_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k131_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k131_ncye=='0.00'){
                                                item.k131_ncye='';
                                            }
                                            if(item.k131_ye=='0.00'){
                                                item.k131_ye='';
                                            }

                                            break;
                                        case "132":
                                            item.k132_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k132_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k132_ncye=='0.00'){
                                                item.k132_ncye='';
                                            }
                                            if(item.k132_ye=='0.00'){
                                                item.k132_ye='';
                                            }

                                            break;
                                        case "135":
                                            item.k135_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k135_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k135_ncye=='0.00'){
                                                item.k135_ncye='';
                                            }
                                            if(item.k135_ye=='0.00'){
                                                item.k135_ye='';
                                            }

                                            break;
                                        case "141":
                                            item.k141_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k141_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k141_ncye=='0.00'){
                                                item.k141_ncye='';
                                            }
                                            if(item.k141_ye=='0.00'){
                                                item.k141_ye='';
                                            }

                                            break;
                                        case "151":
                                            item.k151_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k151_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k151_ncye=='0.00'){
                                                item.k151_ncye='';
                                            }
                                            if(item.k151_ye=='0.00'){
                                                item.k151_ye='';
                                            }

                                            break;
                                        case "161":
                                            item.k161_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k161_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k161_ncye=='0.00'){
                                                item.k161_ncye='';
                                            }
                                            if(item.k161_ye=='0.00'){
                                                item.k161_ye='';
                                            }

                                            break;
                                        case "162":
                                            item.k162_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k162_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k161_ncye=='0.00'){
                                                item.k161_ncye='';
                                            }
                                            if(item.k161_ye=='0.00'){
                                                item.k161_ye='';
                                            }

                                            break;
                                        case "163":
                                            item.k163_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k163_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k163_ncye=='0.00'){
                                                item.k163_ncye='';
                                            }
                                            if(item.k163_ye=='0.00'){
                                                item.k163_ye='';
                                            }

                                            break;
                                        case "201":
                                            item.k201_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k201_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k201_ncye=='0.00'){
                                                item.k201_ncye='';
                                            }
                                            if(item.k201_ye=='0.00'){
                                                item.k201_ye='';
                                            }

                                            break;
                                        case "202":
                                            item.k202_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k202_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k202_ncye=='0.00'){
                                                item.k202_ncye='';
                                            }
                                            if(item.k202_ye=='0.00'){
                                                item.k202_ye='';
                                            }

                                            break;
                                        case "203":
                                            item.k203_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k203_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k203_ncye=='0.00'){
                                                item.k203_ncye='';
                                            }
                                            if(item.k203_ye=='0.00'){
                                                item.k203_ye='';
                                            }

                                            break;
                                        case "211":
                                            item.k211_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k211_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k211_ncye=='0.00'){
                                                item.k211_ncye='';
                                            }
                                            if(item.k211_ye=='0.00'){
                                                item.k211_ye='';
                                            }

                                            break;
                                        case "221":
                                            item.k221_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k221_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k221_ncye=='0.00'){
                                                item.k221_ncye='';
                                            }
                                            if(item.k221_ye=='0.00'){
                                                item.k221_ye='';
                                            }

                                            break;
                                        case "222":
                                            item.k222_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k222_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k222_ncye=='0.00'){
                                                item.k222_ncye='';
                                            }
                                            if(item.k222_ye=='0.00'){
                                                item.k222_ye='';
                                            }

                                            break;
                                        case "225":
                                            item.k225_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k225_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k225_ncye=='0.00'){
                                                item.k225_ncye='';
                                            }
                                            if(item.k225_ye=='0.00'){
                                                item.k225_ye='';
                                            }

                                            break;
                                        case "231":
                                            item.k231_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k231_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k231_ncye=='0.00'){
                                                item.k231_ncye='';
                                            }
                                            if(item.k231_ye=='0.00'){
                                                item.k231_ye='';
                                            }

                                            break;
                                        case "301":
                                            item.k301_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k301_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k301_ncye=='0.00'){
                                                item.k301_ncye='';
                                            }
                                            if(item.k301_ye=='0.00'){
                                                item.k301_ye='';
                                            }

                                            break;
                                        case "302":
                                            item.k302_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k302_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k302_ncye=='0.00'){
                                                item.k302_ncye='';
                                            }
                                            if(item.k302_ye=='0.00'){
                                                item.k302_ye='';
                                            }

                                            break;
                                        case "311":
                                            item.k311_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k311_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k311_ncye=='0.00'){
                                                item.k311_ncye='';
                                            }
                                            if(item.k311_ye=='0.00'){
                                                item.k311_ye='';
                                            }

                                            break;
                                        case "321":
                                            item.k321_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k321_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k321_ncye=='0.00'){
                                                item.k321_ncye='';
                                            }
                                            if(item.k321_ye=='0.00'){
                                                item.k321_ye='';
                                            }

                                            break;
                                        case "322":
                                            item.k322_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k322_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k322_ncye=='0.00'){
                                                item.k322_ncye='';
                                            }
                                            if(item.k322_ye=='0.00'){
                                                item.k322_ye='';
                                            }

                                            break;
                                        case "331":
                                            item.k331_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.k331_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            if(item.k331_ncye=='0.00'){
                                                item.k331_ncye='';
                                            }
                                            if(item.k331_ye=='0.00'){
                                                item.k331_ye='';
                                            }

                                            break;
                                        case "zc_total":
                                            item.zc_total_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.zc_total_ye = $.formatMoney(res.data.list[i].ye, 2);

                                            break;
                                        case "fz_total":
                                            item.fz_total_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.fz_total_ye = $.formatMoney(res.data.list[i].ye, 2);
                                            break;
                                        case "jzc_total":
                                            item.jzc_total_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.jzc_total_ye = $.formatMoney(res.data.list[i].ye, 2);
                                            break;
                                        case "zj_total":
                                            item.zj_total_ncye = $.formatMoney(res.data.list[i].ncye, 2);
                                            item.zj_total_ye = $.formatMoney(res.data.list[i].ye, 2);
                                            break;

                                    }
                                }

                                item.k103_ncye = $.formatMoney( $.unformatMoney2(item.k101_ncye)+$.unformatMoney2(item.k102_ncye),2);
                                item.k103_ye = $.formatMoney( $.unformatMoney2(item.k101_ye)+$.unformatMoney2(item.k102_ye),2);

                                item.k164_ncye = $.formatMoney( $.unformatMoney2(item.k162_ncye)-$.unformatMoney2(item.k163_ncye),2);
                                item.k164_ye = $.formatMoney( $.unformatMoney2(item.k162_ye)-$.unformatMoney2(item.k163_ye),2);

                                item.k144_ncye = $.formatMoney( $.unformatMoney2(item.k103_ncye)+$.unformatMoney2(item.k111_ncye)+$.unformatMoney2(item.k112_ncye)+$.unformatMoney2(item.k131_ncye)+$.unformatMoney2(item.k132_ncye)+$.unformatMoney2(item.k135_ncye)+$.unformatMoney2(item.k141_ncye),2);
                                item.k144_ye = $.formatMoney( $.unformatMoney2(item.k103_ye)+$.unformatMoney2(item.k111_ye)+$.unformatMoney2(item.k112_ye)+$.unformatMoney2(item.k131_ye)+$.unformatMoney2(item.k132_ye)+$.unformatMoney2(item.k135_ye)+$.unformatMoney2(item.k141_ye),2);

                                hiprintTemplate.resetPage();
                                var htmlObj = hiprintTemplate.getHtml(item);
                                $('.prevViewDiv2').html(htmlObj);
                            } else {
                                learun.alert.error(res.resp_msg);
                            }
                        }
                    })
                }
            });
        }
    };

    // 保存数据后回调刷新
    refreshGirdData = function () {
        page.search();
    };

    page.init();
}


